<?php
use Models\Car;
class IndexController extends CI_Controller
{
	public function index ()
	{
		
	}

	public function car(){
		$data['token'] = time().mt_rand(10000,999999);
		$this->session->token = $data['token'];
		$this->load->view('mobile/car.php', $data, FALSE);
	}

	public function car_save(){
		$token = $this->input->post('token');
		if($this->session->token != $token){
			echo json_encode(['code'=>1,'msg'=>'请勿非法提交','token'=>$this->session->token]);
			return;
		}

		$car = new Car;
		$car['name'] = $this->input->post('name');
		$car['phone'] = $this->input->post('phone');
		$car['date'] = $this->input->post('date');
		$car['address'] = $this->input->post('address');
		$car['create_time'] = date('Y-m-d H:i:s');
		$car->add();
		echo json_encode(['code'=>0,'msg'=>'提交成功']);


	}
}